var sysurl = require('url'),
  request = require('request');

exports.run = function(options, req, res, next) {
  var urlObj = sysurl.parse(req.url);
  var proxy, server, port;

  //不是api | activity开头的数据， 直接next
  if (!urlObj.pathname.match(/^\/api|activity|inc/)) {
    next();
    return;
  } else {
    if (!options.proxy) {
      next();
      return;
    }

    request(
      urlObj.protocol || 'http:' + '//' + options.proxy + urlObj.href,
      function(error, response, body) {
        if (!error && response.statusCode == 200) {
          res.end(body);
        }

        next();
      });
  }


};
